/*
 * SetTransitionNameCommand.java
 *
 * Created on 26 maj 2007, 16:13
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package edu.uj.petri.commands;

import edu.uj.petri.model.Transition;
import java.util.ResourceBundle;

/**
 *
 * @author Paweł
 */
public class SetTransitionNameCommand extends Command {
    
    private Transition transition;
    private String newName;
    private String oldName;
    
    /** Creates a new instance of SetTransitionNameCommand */
    public SetTransitionNameCommand( Transition transition, String name) {
        this.transition = transition;
        this.newName = name;
        oldName = null;
    }

    public String toString() {
        return ResourceBundle.getBundle("edu/uj/petri/messages").getString("zmiana_nazwy_tranzycji");
    }

    void execute() {
        if (oldName == null)
            oldName = transition.getName();
        transition.setName(newName);
    }

    void undo() {
        transition.setName(oldName);
    }

    boolean canBeCombined(Command c) {
        return false;
    }

    private static final long serialVersionUID = 7555613657699659567L;
    
}
